package cn.ultrarisk.scadmin.manager.biz.monitor.entity;

import cn.ultrarisk.scadmin.manager.biz.solr.context.SolrCacheType;
import cn.ultrarisk.scadmin.manager.biz.solr.entity.SolrReplica;
import cn.ultrarisk.mybatis.extension.annotation.Table;

import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * solr缓存监控实体类
 *
 * @author sevendlong(lin23871@163.com)
 * @date 2014/4/14
 * @since V1.0
 */
@Table(table = "solr_cache_monitor", idColumn = SolrCacheMonitor.ID, autoIncrement = true)
public class SolrCacheMonitor implements Serializable {
    private static final long serialVersionUID = -3853511056444939104L;

    public final static String ID = "id";
    public final static String NODE_ID = "node_id";
    public final static String COLLECTION_ID = "collection_id";
    public final static String SHARD_ID = "shard_id";
    public final static String REPLICA_ID = "replica_id";
    public final static String TYPE = "type";
    public final static String LOOKUPS = "lookups";
    public final static String HITS = "hits";
    public final static String INSERTS = "inserts";
    public final static String EVICTIONS = "evictions";
    public final static String ENTRIES_COUNT = "entries_count";
    public final static String INSANITY_COUNT = "insanity_count";
    public final static String SIZE = "size";
    public final static String CREATE_TIME = "create_time";

    public static final Map<String, String> COLUMN_PROPERTY_MAP = new LinkedHashMap<String, String>();

    static {
        COLUMN_PROPERTY_MAP.put(ID, "id");
        COLUMN_PROPERTY_MAP.put(NODE_ID, "nodeId");
        COLUMN_PROPERTY_MAP.put(COLLECTION_ID, "collectionId");
        COLUMN_PROPERTY_MAP.put(SHARD_ID, "shardId");
        COLUMN_PROPERTY_MAP.put(REPLICA_ID, "replicaId");
        COLUMN_PROPERTY_MAP.put(TYPE, "type");
        COLUMN_PROPERTY_MAP.put(LOOKUPS, "lookups");
        COLUMN_PROPERTY_MAP.put(HITS, "hits");
        COLUMN_PROPERTY_MAP.put(INSERTS, "inserts");
        COLUMN_PROPERTY_MAP.put(EVICTIONS, "evictions");
        COLUMN_PROPERTY_MAP.put(ENTRIES_COUNT, "entriesCount");
        COLUMN_PROPERTY_MAP.put(INSANITY_COUNT, "insanityCount");
        COLUMN_PROPERTY_MAP.put(SIZE, "size");
        COLUMN_PROPERTY_MAP.put(CREATE_TIME, "createTime");
    }

    /**
     * id
     */
    private Long id;
    /**
     * 节点id
     */
    private Integer nodeId;
    /**
     * 集合id
     */
    private Integer collectionId;
    /**
     * 分片id
     */
    private Integer shardId;
    /**
     * 副本id
     */
    private Integer replicaId;
    /**
     * 缓存类型
     */
    private SolrCacheType type;
    /**
     * 查找数
     */
    private Long lookups;
    /**
     * 命中数
     */
    private Long hits;
    /**
     * 插入数
     */
    private Long inserts;
    /**
     * 置换数
     */
    private Long evictions;
    /**
     * entries
     */
    private Integer entriesCount;
    /**
     * insanity
     */
    private Integer insanityCount;
    /**
     * 缓存数
     */
    private Long size;
    /**
     * 创建时间
     */
    private Long createTime;

    public SolrCacheMonitor() {
    }

    public SolrCacheMonitor(SolrReplica replica, SolrCacheType type) {
        this.nodeId = replica.getNodeId();
        this.collectionId = replica.getCollectionId();
        this.shardId = replica.getShardId();
        this.replicaId = replica.getId();
        this.type = type;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Integer getNodeId() {
        return nodeId;
    }

    public void setNodeId(Integer nodeId) {
        this.nodeId = nodeId;
    }

    public Integer getCollectionId() {
        return collectionId;
    }

    public void setCollectionId(Integer collectionId) {
        this.collectionId = collectionId;
    }

    public Integer getShardId() {
        return shardId;
    }

    public void setShardId(Integer shardId) {
        this.shardId = shardId;
    }

    public Integer getReplicaId() {
        return replicaId;
    }

    public void setReplicaId(Integer replicaId) {
        this.replicaId = replicaId;
    }

    public SolrCacheType getType() {
        return type;
    }

    public void setType(SolrCacheType type) {
        this.type = type;
    }

    public Long getLookups() {
        return lookups;
    }

    public void setLookups(Long lookups) {
        this.lookups = lookups;
    }

    public Long getHits() {
        return hits;
    }

    public void setHits(Long hits) {
        this.hits = hits;
    }

    public Long getInserts() {
        return inserts;
    }

    public void setInserts(Long inserts) {
        this.inserts = inserts;
    }

    public Long getEvictions() {
        return evictions;
    }

    public void setEvictions(Long evictions) {
        this.evictions = evictions;
    }

    public Integer getEntriesCount() {
        return entriesCount;
    }

    public void setEntriesCount(Integer entriesCount) {
        this.entriesCount = entriesCount;
    }

    public Integer getInsanityCount() {
        return insanityCount;
    }

    public void setInsanityCount(Integer insanityCount) {
        this.insanityCount = insanityCount;
    }

    public Long getSize() {
        return size;
    }

    public void setSize(Long size) {
        this.size = size;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

}